package com.anycl.design.behavioral.strategy;

/**
 * 上下文角色
 */
public class Context {
    private Strategy strategy;

    public Context(String strategyNum) {
        Strategy strategy;
        switch (strategyNum) {
            case "1":
                strategy = new ConcreteStrategy1();
                break;
            case "2":
            default:
                strategy = new ConcreteStrategy2();
        }
        this.strategy = strategy;
    }

    public void doStrategy() {
        this.strategy.algorithm();
    }
}
